package com.toocms.jinjuhang.ui.mine.setting.feedback

import android.app.Application
import androidx.databinding.ObservableField
import com.toocms.jinjuhang.config.Urls
import com.toocms.jinjuhang.widget.view_model.requestData
import com.toocms.tab.base.BaseModel
import com.toocms.tab.base.BaseViewModel
import com.toocms.tab.binding.command.BindingAction
import com.toocms.tab.binding.command.BindingCommand

class FeedbackModel(application: Application) : BaseViewModel<BaseModel>(application) {

    val titleObservableField = ObservableField<String>()
    val contentObservableField = ObservableField<String>()
    val contactObservableField = ObservableField<String>()

    val submitFeedbackClickBindingCommand = BindingCommand<BindingAction>(BindingAction {
        val params = mutableMapOf<String, String?>()
        params["title"] = titleObservableField.get()
        params["content"] = contentObservableField.get()
        params["contact"] = contactObservableField.get()
        requestData(Urls.System.FEEDBACK, params, resultClass = String::class.java, result = {
            showToast(it)
            finishFragment()
        })
    })
}